package com.ruoyi.system.controller;

import java.util.List;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;

import lombok.RequiredArgsConstructor;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.validate.AddGroup;
import com.ruoyi.common.core.validate.EditGroup;
import com.ruoyi.common.core.validate.QueryGroup;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.vo.KfnWorkOrderStoreRichemontVo;
import com.ruoyi.system.domain.bo.KfnWorkOrderStoreRichemontBo;
import com.ruoyi.system.service.IKfnWorkOrderStoreRichemontService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 历峰店铺
 *
 * @author Panda
 * @date 2024-01-05
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/system/workOrderStoreRichemont")
public class KfnWorkOrderStoreRichemontController extends BaseController {

    private final IKfnWorkOrderStoreRichemontService iKfnWorkOrderStoreRichemontService;

    /**
     * 查询历峰店铺列表
     */
    @SaCheckPermission("system:workOrderStoreRichemont:list")
    @GetMapping("/list")
    public TableDataInfo<KfnWorkOrderStoreRichemontVo> list(KfnWorkOrderStoreRichemontBo bo, PageQuery pageQuery) {
        return iKfnWorkOrderStoreRichemontService.queryPageList(bo, pageQuery);
    }

    /**
     * 导出历峰店铺列表
     */
    @SaCheckPermission("system:workOrderStoreRichemont:export")
    @Log(title = "历峰店铺", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(KfnWorkOrderStoreRichemontBo bo, HttpServletResponse response) {
        List<KfnWorkOrderStoreRichemontVo> list = iKfnWorkOrderStoreRichemontService.queryList(bo);
        ExcelUtil.exportExcel(list, "历峰店铺", KfnWorkOrderStoreRichemontVo.class, response);
    }

    /**
     * 获取历峰店铺详细信息
     *
     * @param storeId 主键
     */
    @SaCheckPermission("system:workOrderStoreRichemont:query")
    @GetMapping("/{storeId}")
    public R<KfnWorkOrderStoreRichemontVo> getInfo(@NotNull(message = "主键不能为空")
                                     @PathVariable Long storeId) {
        return R.ok(iKfnWorkOrderStoreRichemontService.queryById(storeId));
    }

    /**
     * 新增历峰店铺
     */
    @SaCheckPermission("system:workOrderStoreRichemont:add")
    @Log(title = "历峰店铺", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    public R<Void> add(@Validated(AddGroup.class) @RequestBody KfnWorkOrderStoreRichemontBo bo) {
        return toAjax(iKfnWorkOrderStoreRichemontService.insertByBo(bo));
    }

    /**
     * 修改历峰店铺
     */
    @SaCheckPermission("system:workOrderStoreRichemont:edit")
    @Log(title = "历峰店铺", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody KfnWorkOrderStoreRichemontBo bo) {
        return toAjax(iKfnWorkOrderStoreRichemontService.updateByBo(bo));
    }

    /**
     * 删除历峰店铺
     *
     * @param storeIds 主键串
     */
    @SaCheckPermission("system:workOrderStoreRichemont:remove")
    @Log(title = "历峰店铺", businessType = BusinessType.DELETE)
    @DeleteMapping("/{storeIds}")
    public R<Void> remove(@NotEmpty(message = "主键不能为空")
                          @PathVariable Long[] storeIds) {
        return toAjax(iKfnWorkOrderStoreRichemontService.deleteWithValidByIds(Arrays.asList(storeIds), true));
    }
}
